<?php
error_reporting ( E_ALL );
$PageSecurity = 14;
include_once ('includes/session.inc');
set_time_limit ( 0 );

$action = isset ( $_POST ['action'] ) ? $_POST ['action'] : '';

if ($action == 'getPartner') {
    $result = _single ( 'api/partner' )->GetAllPartner ( $_SESSION ['UserID'], $_SESSION ['Password'] );

    $data = '{"success":true';
    $data .= ',"data":[';
    $haveData = false;

    while ( $row = DB_fetch_array ( $result ) ) {
        $haveData = true;
        $data .= sprintf ( '{"partner_id":"%s","partner_number":"%s","partner_name":"%s"},', $row ['partner_id'], $row ['partner_number'], $row ['partner_name'] );
    }

    if ($haveData) {
        $data = substr ( $data, 0, strlen ( $data ) - 1 );
    }

    $data .= '],"count":"' . json_encode ( $total ) . '"}';
    echo $data;
} elseif ($action == 'getObject') {
    $total = 0;
    $condition = array ();
    if (! empty ( $_POST ['query'] ))
        $condition ['object_name'] = "N'%" . DB_escape_string ( $_POST ['query'] ) . "%'";

    $result = _single ( 'api/object' )->loadObjects ( null, $_POST ['limit'], $_POST ['start'], $total, $_SESSION ['UserID'], $_SESSION ['Password'], $condition );

    $data = '{"success":true';
    $data .= ',"data":[';
    $haveData = false;

    while ( $row = DB_fetch_array ( $result ) ) {
        $haveData = true;
        $data .= sprintf ( '{"object_id":"%s","object_number":"%s","object_name":"%s"},', $row ['object_id'], $row ['object_number'], $row ['object_name'] );
    }

    if ($haveData) {
        $data = substr ( $data, 0, strlen ( $data ) - 1 );
    }

    $data .= '],"count":"' . json_encode ( $total ) . '"}';
    echo $data;
} elseif ($action == 'getPartnerPrices') {
    $result = _single ( 'api/partner_prices' )->getAllPartnerPricesByPartnerId ( DB_escape_string ( trim ( $_POST ['partner_id'] ) ) );

    $data = '{"success":true';
    $data .= ',"data":[';
    $haveData = false;

    while ( $row = DB_fetch_array ( $result ) ) {
        $haveData = true;
        $data .= sprintf ( '{"id":"%s","price":"%s"},', $row ['id'], $row ['price'] );
    }

    if ($haveData) {
        $data = substr ( $data, 0, strlen ( $data ) - 1 );
    }

    $data .= '],"count":"' . json_encode ( $total ) . '"}';
    echo $data;
} elseif ($_GET ['action'] == 'export') {

    $DEFAULT_EXPORT_FILE_NAME = 'BienBanDoiSoat';
    $DEFAULT_DIR_UPLOAD = 'tmp/exported/';
    $DEFAULT_EXCEL_TYPE = 'Excel5'; // default Excel 2003 - Excel5,Excel2007

    $titleObject = '';
    $titleDaidien = '';
    $Object = _single ( 'api/object' )->GetObjectById ( $_GET ['object'], $_SESSION ['UserID'], $_SESSION ['Password'] );
    switch ($_GET ['type']) {
        case 1 :
            $titleObject = 'Ca sĩ';
            $titleDaidien = 'ĐẠI DIỆN CA SỸ';
            break;
        case 2 :
            $titleObject = 'Nhạc sĩ';
            $titleDaidien = 'ĐẠI DIỆN NHẠC SỸ';
            break;
        default :
            break;
    }
    ;
    $docquyen = '';
    $ReleaseAuthority = null;
    if ($_GET ['release'] != - 1) {
        $ReleaseAuthority = $_GET ['release'];
        if ($_GET ['release'] == 1) {
            $docquyen = 'độcquyền';
        } else {
            $docquyen = 'khôngđộcquyền';
        }
    }
    // detail
    // lay du lieu
    $partnerPriceObj = _single ( 'api/partner_prices' )->GetPartnerPriceById ( $_GET ['partnerPriceId'], $_SESSION ['UserID'], $_SESSION ['Password'] );
    $partnerPrice = $_GET ['partnerPrice'];
    $result = _single ( 'api/exchange' )->GetYieldRevenue ( $_GET ['partnerId'], $partnerPrice, $_GET ['object'], $_GET ['type'], $_GET ['fdate'], $_GET ['tdate'], null, null, $ReleaseAuthority, null, null, $total, $_SESSION ['UserID'], $_SESSION ['Password'] );
    $Objects = array ();
    while ( $row = DB_fetch_array ( $result ) ) {
        $Objects [$row ['exchange_imported_date']] [] = $row;
    }
    $title = '';
    foreach ( $Objects as $key => $value ) {
        $title .= $key . ',';
    }
    if (! empty ( $title )) {
        $title = substr ( $title, 0, strlen ( $title ) - 1 );
    }

    // end xac dinh dang report
    $DEFAULT_EXPORT_FILE_NAME .= '-' . str_replace ( ' ', '', $titleObject ) . '-' . str_replace ( ' ', '', $Object ['object_name'] ) . '-' . $title . '-' . $docquyen;

    $objPHPExcel = new Api_Excel ( $DEFAULT_EXPORT_FILE_NAME, $DEFAULT_DIR_UPLOAD, $DEFAULT_EXCEL_TYPE );
    $objPHPExcel->setActiveSheet ( 0 );

    $aligment_HorCent_VerCent = array (
            'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
            'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER
    );

    $aligment_HorCent_VerBottom = array (
            'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
            'vertical' => PHPExcel_Style_Alignment::VERTICAL_BOTTOM
    );

    $border_thin = array (
            'style' => PHPExcel_Style_Border::BORDER_THIN
    );
    $border_thin_ALL_title = array (
            'borders' => array (
                    'top' => $border_thin,
                    'right' => $border_thin,
                    'bottom' => $border_thin,
                    'left' => $border_thin
            ),
            'alignment' => $aligment_HorCent_VerCent,
            'font' => array (
                    'bold' => true
            )
    );

    $border_thin_ALL = array (
            'borders' => array (
                    'top' => $border_thin,
                    'right' => $border_thin,
                    'bottom' => $border_thin,
                    'left' => $border_thin
            ),
            'alignment' => $aligment_HorCent_VerBottom,
            'font' => array (
                    'bold' => false,
                    'size' => 10,
                    'color' => array (
                            'argb' => 'FFFF0000'
                    )
            )
    );

    // set default style
    $objPHPExcel->setPageSetup ( 85, PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4, PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT );
    $objPHPExcel->setDefaultStyle ( 'Times New Roman', 10 );
    // $objPHPExcel->setFreezePane("E13");
    $objPHPExcel->setPageMargins ( 0.5, 0.25, 0, 0.75 );
    $objPHPExcel->setHorizontalCentered ( true );

    $objPHPExcel->setColumnWidth ( "A", 9 )->setColumnWidth ( "B", 16 )->setColumnWidth ( "C", 28 )->setColumnWidth ( "D", 21 )->setColumnWidth ( "E", 21 )->setColumnWidth ( "F", 10 )->setColumnWidth ( "G", 10 )->setColumnWidth ( "H", 14 )->setColumnWidth ( "I", 18 )->setColumnWidth ( "J", 18 )->setColumnWidth ( "K", 18 )->setColumnWidth ( "L", 15 );

    $objPHPExcel->mergeCells ( "A1", "K1" )->setText ( "A1", "CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM", false, false, false, 12 )->setCellHorizontalAllignment ( "A1", 'center' )->setRowHeight ( 1, 18 )->mergeCells ( "A2", "K2" )->setText ( "A2", "Độc Lập - Tự Do - Hạnh Phúc\n------------------o0o-------------------", false, false, false, 12 )->setCellHorizontalAllignment ( "A2", 'center' )->setWrapText ( "A2" )->setRowHeight ( 2, 30 )->setRowHeight ( 3, 18 )->mergeCells ( "A4", "K4" )->setText ( "A4", "BIÊN BẢN ĐỐI SOÁT CHI PHÍ BẢN QUYỀN", true, false, false, 16 )->setCellHorizontalAllignment ( "A4", 'center' )->mergeCells ( "A5", "K5" )->setText ( "A5", "DỊCH VỤ NHẠC CHỜ VIETTEL THÁNG $title", true, false, false, 16 )->setCellHorizontalAllignment ( "A5", 'center' )->setRowHeight ( 6, 22 )->setCellBackgroundColor ( "A7:K7", PHPExcel_Style_Fill::FILL_SOLID, "FFFF00" )->setRowHeight ( 7, 20 )->setText ( "B7", "$titleObject", true, false, false, 12 )->setText ( "C7", ":" . $Object ['object_name'], true, false, false, 12 )->setText ( "B8", "Theo hợp đồng số", false, false, false, 10 )->setText ( "C8", ": " . $Object ['contract_number'], false, false, false, 10 )->setCellForegroundColor ( "C8", "FF0000" )->setRowHeight ( 7, 18 );

    $Position = 10;
    $SumRowArray = array ();
    $MoneyExtraSinger = array (); // tien cong them cho ca si la nhac si cho bai hat
    $TOTAL = 0;
    foreach ( $Objects as $key => $value ) {
        $objPHPExcel->mergeCells ( "A$Position", "K$Position" )->setCellBackgroundColor ( "A$Position", PHPExcel_Style_Fill::FILL_SOLID, "FFFF00" )->setText ( "A$Position", "Tháng " . $key, true, false, false, 16 )->setCellHorizontalAllignment ( "A$Position", 'center' );
        $Position += 2;
        $objPHPExcel->mergeCells ( "A" . ($Position - 1), "A" . ($Position) )->mergeCells ( "B" . ($Position - 1), "B" . ($Position) )->mergeCells ( "C" . ($Position - 1), "C" . ($Position) )->mergeCells ( "D" . ($Position - 1), "D" . ($Position) )->mergeCells ( "E" . ($Position - 1), "E" . ($Position) )->mergeCells ( "F" . ($Position - 1), "F" . ($Position) )->mergeCells ( "G" . ($Position - 1), "G" . ($Position) )->mergeCells ( "H" . ($Position - 1), "H" . ($Position) )->setText ( "A" . ($Position - 1), "Stt" )->setText ( "B" . ($Position - 1), "Mã số" )->setText ( "C" . ($Position - 1), "Tên bài hát" )->setText ( "D" . ($Position - 1), "Ca sĩ" )->setText ( "E" . ($Position - 1), "Nhạc sĩ" )->setText ( "F" . ($Position - 1), "Số lượng" )->setText ( "G" . ($Position - 1), "Giá" )->setText ( "H" . ($Position - 1), "Tổng giá tiền" )->setWrapText ( "H" . ($Position - 1) )->setDuplicateStyleArray ( $border_thin_ALL_title, "A" . ($Position - 1), "A$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "B" . ($Position - 1), "B$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "C" . ($Position - 1), "C$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "D" . ($Position - 1), "D$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "E" . ($Position - 1), "E$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "F" . ($Position - 1), "F$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "G" . ($Position - 1), "G$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "H" . ($Position - 1), "H$Position" )->setCellBackgroundColor ( "A" . ($Position - 1) . ":H$Position", PHPExcel_Style_Fill::FILL_SOLID, "C0C0C0" )->setRowHeight ( $Position - 1, 30 )->setRowHeight ( $Position, 55 )->

        mergeCells ( "I" . ($Position - 1), "K" . ($Position - 1) )->setText ( "I" . ($Position - 1), "Tổng chi phí bản quyền được phân chia : $partnerPrice (VNĐ)" )->setWrapText ( "I" . ($Position - 1) )->setDuplicateStyleArray ( $border_thin_ALL_title, "I" . ($Position - 1), "K" . ($Position - 1) )->

        setText ( "I" . ($Position), "Tổng phí trả cho bản quyền tác giả (nhạc sĩ) 108.8 VNĐ Tỷ lệ 40%" )->setWrapText ( "I" . ($Position) )->setDuplicateStyleArray ( $border_thin_ALL_title, "I" . ($Position), "I" . ($Position) )->

        setText ( "J" . ($Position), "Tổng phí trả cho bản quyền ghi âm (ca sĩ) 81.6 VNĐ Tỷ lệ 30%" )->setWrapText ( "J" . ($Position) )->setDuplicateStyleArray ( $border_thin_ALL_title, "J" . ($Position), "J" . ($Position) )->

        setText ( "K" . ($Position), "Tổng phí trả cho quyền bên liên quan (phát hành) 81.6 VNĐ Tỷ lệ 30%" )->setWrapText ( "K" . ($Position) )->setDuplicateStyleArray ( $border_thin_ALL_title, "K" . ($Position), "K" . ($Position) )->

        setCellBackgroundColor ( "I" . ($Position - 1) . ":K$Position", PHPExcel_Style_Fill::FILL_SOLID, "C0C0C0" )->setRowHeight ( $Position, 65 );


        $StartRow = $Position ++;
        $cFormulaTongTien = "";
        $cFormulaTacgia = "";
        $cFormulaGhiam = "";
        $cFormulaPhathanh = "";
        $MoneyExtraSingerForMonth = array (); // tien cong them cho ca si la nhac si cho bai hat
        for($i = 0; $i < count ( $value ); $i ++) {
            $cFormulaTongTien = "=F$Position*G$Position";
            $cFormulaTacgia = "=H$Position*40/100";
            $cFormulaGhiam = "=H$Position*30/100";
            $cFormulaPhathanh = "=H$Position*30/100";
            if ($_GET ['type'] == 1) {
                if ($value [$i] ['singer_id'] == $value [$i] ['composer_id']) {
                    $MoneyExtraSinger [] = "I$Position";
                    $MoneyExtraSingerForMonth [] = "I$Position";
                    $TOTAL += $value [$i] ['money_composer'];
                }
                $TOTAL += $value [$i] ['money_singer'] + $value [$i] ['money_release'];
            } elseif ($_GET ['type'] == 2) {
                $TOTAL += $value [$i] ['money_composer'];
            }

            $objPHPExcel->setDuplicateStyleArray ( $border_thin_ALL, "A" . ($Position), "A$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "B" . ($Position), "B$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "C" . ($Position), "C$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "D" . ($Position), "D$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "E" . ($Position), "E$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "F" . ($Position), "F$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "G" . ($Position), "G$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "H" . ($Position), "H$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "I" . ($Position), "I$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "J" . ($Position), "J$Position" )->setDuplicateStyleArray ( $border_thin_ALL, "K" . ($Position), "K$Position" )->

            setText ( "A" . ($Position), ($i + 1) )->setText ( "B" . ($Position), $value [$i] ['song_number'] )->setCellHorizontalAllignment ( "A" . ($Position), 'center' )->setCellHorizontalAllignment ( "B" . ($Position), 'center' )->setText ( "C" . ($Position), $value [$i] ['song_name'] )->setText ( "D" . ($Position), empty ( $value [$i] ['song_singer_sing'] ) ? $value [$i] ['singer_name'] : $value [$i] ['song_singer_sing'] )->setText ( "E" . ($Position), $value [$i] ['composer_name'] )->

            setValueExplicit ( "F" . $Position, $value [$i] ['exchange_quantity'] * 0.85, PHPExcel_Cell_DataType::TYPE_NUMERIC )->setFormatCode ( "F" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "F" . $Position, "right" )->setValueExplicit ( "G" . $Position, $value [$i] ['exchange_price'], PHPExcel_Cell_DataType::TYPE_NUMERIC )->setFormatCode ( "G" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "G" . $Position, "right" )->setText ( "H$Position", "$cFormulaTongTien", false )->setFormatCode ( "H" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "H" . $Position, "right" )->

            setText ( "I$Position", "$cFormulaTacgia", false )->setFormatCode ( "I" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "I" . $Position, "right" )->setText ( "J$Position", "$cFormulaGhiam", false )->setFormatCode ( "J" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "J" . $Position, "right" )->setText ( "K$Position", "$cFormulaPhathanh", false )->setFormatCode ( "K" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "K" . $Position, "right" )->

            setText ( "M$Position", $partnerPriceObj ['note'], false )->

            setRowHeight ( $Position, 16 );
            $Position ++;
        }
        $EndRow = $Position - 1;
        $cFormulaTongSanluong = "=SUM(F$StartRow:F$EndRow)";
        $cFormulaTongTien = "=SUM(H$StartRow:H$EndRow)";
        $cFormulaTongTacgia = "=SUM(I$StartRow:I$EndRow)";
        $cFormulaTongGhiam = "=SUM(J$StartRow:J$EndRow)";
        $cFormulaTongPhathanh = "=SUM(K$StartRow:K$EndRow)";
        $objPHPExcel->mergeCells ( "A" . ($Position), "E" . ($Position) )->setDuplicateStyleArray ( $border_thin_ALL_title, "A" . ($Position), "E$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "F" . ($Position), "F$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "G" . ($Position), "G$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "H" . ($Position), "H$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "I" . ($Position), "I$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "J" . ($Position), "J$Position" )->setDuplicateStyleArray ( $border_thin_ALL_title, "K" . ($Position), "K$Position" )->setCellHorizontalAllignment ( "A" . ($Position), 'center' )->setText ( "A" . ($Position), "TỔNG CỘNG" )->setText ( "F$Position", "$cFormulaTongSanluong", true )->setFormatCode ( "F" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "F" . $Position, "right" )->

        setText ( "H$Position", "$cFormulaTongTien", true )->setFormatCode ( "H" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "H" . $Position, "right" )->setText ( "I$Position", "$cFormulaTongTacgia", true )->setFormatCode ( "I" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "I" . $Position, "right" )->setText ( "J$Position", "$cFormulaTongGhiam", true )->setFormatCode ( "J" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "J" . $Position, "right" )->setText ( "K$Position", "$cFormulaTongPhathanh", true )->setFormatCode ( "K" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "K" . $Position, "right" );

        // cong thuc tinh them tinh nhac sy cho thang
        foreach ( $MoneyExtraSingerForMonth as $value ) {
            $objPHPExcel->setCellBold ( $value, true );
        }
        if (! empty ( $MoneyExtraSingerForMonth )) {
            $MoneyExtraSingerForMonth = implode ( "+", $MoneyExtraSingerForMonth );
        } else {
            $MoneyExtraSingerForMonth = "0";
        }
        $objPHPExcel->setText ( "L" . ($EndRow - 1), "=" . $MoneyExtraSingerForMonth, true )->setFormatCode ( "L" . ($EndRow - 1), $FormatCurrencyExport )->setCellHorizontalAllignment ( "L" . ($EndRow - 1), "right" );
        if ($_GET ['type'] == 1) {
            $objPHPExcel->setText ( "L" . ($EndRow), "=" . "J$Position+K$Position", true )->setFormatCode ( "L" . ($EndRow), $FormatCurrencyExport )->setCellHorizontalAllignment ( "L" . ($EndRow), "right" );
        } elseif ($_GET ['type'] == 2) { // truong hop nhac si
            $objPHPExcel->setText ( "L" . ($EndRow), "=" . "I$Position", true )->setFormatCode ( "L" . ($EndRow), $FormatCurrencyExport )->setCellHorizontalAllignment ( "L" . ($EndRow), "right" );
        }
        $objPHPExcel->setText ( "L" . ($Position), "=L" . ($EndRow - 1) . "+L" . $EndRow, true )->setFormatCode ( "L" . ($Position), $FormatCurrencyExport )->setCellHorizontalAllignment ( "L" . ($Position), "right" );
        // //// end cong thuc tinh them tinh nhac sy cho thang

        $SumRowArray [] = $Position;
        $Position ++;
        $objPHPExcel->setRowHeight ( $Position, 18 );
        $Position ++;
    }

    // truong hop nhac sy
    $cFormulaTong = array ();
    if ($_GET ['type'] == 1) {
        foreach ( $SumRowArray as $value ) {
            $cFormulaTong [] = "J$value+K$value";
        }
    } elseif ($_GET ['type'] == 2) { // truong hop nhac si
        foreach ( $SumRowArray as $value ) {
            $cFormulaTong [] = "I$value";
        }
    }
    if (! empty ( $MoneyExtraSinger )) {
        $MoneyExtraSinger = implode ( "+", $MoneyExtraSinger );
    } else {
        $MoneyExtraSinger = "0";
    }

    if (! empty ( $cFormulaTong )) {
        $cFormulaTong = "=" . implode ( "+", $cFormulaTong ) . "+" . $MoneyExtraSinger;
    } else {
        $cFormulaTong = "";
    }

    $cFormulaThue = "=J$Position*10/100";
    $cFormulaConlai = "=J$Position-J" . ($Position + 1);

    $TOTAL = $TOTAL - ($TOTAL * 10 / 100);
    $TOTAL = round ( $TOTAL, 0 );
    $objPHPExcel->setText ( "A$Position", "Tổng số tiền Công Ty TNHH MTV TMDV QC Việt Giải Trí phải thanh toán tháng $title là :", false, false, false, 11 )->setText ( "A" . ($Position + 1), "Thuế TNCN 10% :", false, false, false, 11 )->setText ( "A" . ($Position + 2), "Số tiền còn lại :", false, false, false, 11 )->setText ( "A" . ($Position + 3), "Bằng chữ:", false, false, false, 11 )->setText ( "K" . ($Position), "VNĐ", false, false, false, 11 )->setText ( "K" . ($Position + 1), "VNĐ", false, false, false, 11 )->setText ( "K" . ($Position + 2), "VNĐ", false, false, false, 11 )->setText ( "C" . ($Position + 3), ucfirst ( convertNumberToString ( ( string ) $TOTAL ) ), true, false, true, 11, false )->setText ( "J" . ($Position), "$cFormulaTong", false )->setFormatCode ( "J" . $Position, $FormatCurrencyExport )->setCellHorizontalAllignment ( "J" . $Position, "right" )->setText ( "J" . ($Position + 1), "$cFormulaThue", false )->setFormatCode ( "J" . ($Position + 1), $FormatCurrencyExport )->setCellHorizontalAllignment ( "J" . ($Position + 1), "right" )->setText ( "J" . ($Position + 2), "$cFormulaConlai", true, false, false, 12 )->setFormatCode ( "J" . ($Position + 2), $FormatCurrencyExport )->setCellHorizontalAllignment ( "J" . ($Position + 2), "right" );
    $Position += 5;
    $objPHPExcel->setText ( "H" . ($Position), "Ngày …..tháng …..năm " . date ( "Y" ) . ".", false, false, true, 11 )->setText ( "B" . ($Position + 1), "CÔNG TY TNHH MTV TM DV QC VIỆT GIẢI TRÍ", true, false, false, 11 )->setText ( "G" . ($Position + 1), "$titleDaidien", true, false, false, 11 )->setText ( "B" . ($Position + 2), "P. GIÁM ĐỐC", false, false, false, 11 )->setCellHorizontalAllignment ( "B" . ($Position + 2), "right" )->setText ( "D" . ($Position + 2), "P.ĐỐI SOÁT", false, false, false, 11 )->

    setText ( "B" . ($Position + 6), "LÊ THỊ THỦY ANH", true, false, false, 11 )->setText ( "D" . ($Position + 6), "VÕ NGỌC MINH THY", true, false, false, 11 );

    $objPHPExcel->outputToBrowser ();
    exit ();
}
?>